# from rest_framework import serializers
# from .models import Scene, Trigger, Action, SceneExecutionLog


# class TriggerSerializer(serializers.ModelSerializer):
#     class Meta:
#         model = Trigger
#         fields = ('id', 'scene', 'type', 'config')
#         read_only_fields = ('scene',)


# class ActionSerializer(serializers.ModelSerializer):
#     class Meta:
#         model = Action
#         fields = ('id', 'scene', 'device_id', 'command')
#         read_only_fields = ('scene',)


# class SceneSerializer(serializers.ModelSerializer):
#     class Meta:
#         model = Scene
#         fields = ('id', 'name', 'owner', 'priority', 'enabled', 'created_at', 'updated_at')
#         read_only_fields = ('created_at', 'updated_at')
    
#     def create(self, validated_data):
#         # 自动将 owner 设为当前用户
#         request = self.context['request']
#         return Scene.objects.create(owner=request.user, **validated_data)


# class SceneDetailSerializer(SceneSerializer):
#     triggers = TriggerSerializer(many=True, read_only=True)
#     actions = ActionSerializer(many=True, read_only=True)

#     class Meta(SceneSerializer.Meta):
#         fields = SceneSerializer.Meta.fields + ('triggers', 'actions')


# class SceneExecutionLogSerializer(serializers.ModelSerializer):
#     class Meta:
#         model = SceneExecutionLog
#         fields = ('id', 'scene', 'invoker', 'status', 'detail', 'ts')
#         read_only_fields = ('ts',)